package com.barunsw.bwf.neoarena_erp.repair_record_list;

import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.neoarena_erp.vo.RepairOrderVo;
import com.barunsw.bwf.neoarena_erp.vo.RepairRecordVo;

@Controller
@RequestMapping("/repair_record_list")
public class RepairRecordListController {
	private static final Logger LOGGER = LoggerFactory.getLogger(RepairRecordListController.class);
	
	@Autowired
	private RepairRecordService repairRecordService;
	
	@RequestMapping(value = "", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		return "repair_record_list/repair_record_list";
	}
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public @ResponseBody List<RepairRecordVo> list(
			@RequestBody @RequestParam(value="acceptStartDate", required=false) String acceptStartDate,
			@RequestBody @RequestParam(value="acceptEndDate", required=false) String acceptEndDate,
			@RequestBody @RequestParam(value="customerCode", required=false) String customerCode,
			@RequestBody @RequestParam(value="operatorCode", required=false) String operatorCode,
			@RequestBody @RequestParam(value="repairCenterCode", required=false) String repairCenterCode,
			@RequestBody @RequestParam(value="serialNo", required=false) String serialNo,
			@RequestBody @RequestParam(value="replaceSerialNo", required=false) String replaceSerialNo,
			@RequestBody @RequestParam(value="projectCode", required=false) String projectCode
		) throws Exception {
		
		RepairRecordVo repairRecordVo = new RepairRecordVo();
		repairRecordVo.setAcceptStartDate(acceptStartDate);
		repairRecordVo.setAcceptEndDate(acceptEndDate);
		repairRecordVo.setCustomerCode(customerCode);
		repairRecordVo.setOperatorCode(operatorCode);
		repairRecordVo.setRepairCenterCode(repairCenterCode);
		repairRecordVo.setSerialNo(serialNo);
		repairRecordVo.setReplaceSerialNo(replaceSerialNo);
		repairRecordVo.setProjectCode(projectCode);
		
		List<RepairRecordVo> repairRecordList = repairRecordService.selectList(repairRecordVo);
		
		return repairRecordList;
	}
}
